package cn.desk.listener;
import com.opensymphony.xwork2.validator.ValidationException;
import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;


public class RequiredIntegerValidator extends FieldValidatorSupport {

	@Override
	public void validate(Object object) throws ValidationException {
		 String fieldName = getFieldName();
	        Object value = this.getFieldValue(fieldName, object);

	        if (!(value instanceof Integer)) {
	            addFieldError(fieldName, object);
	        } else {
	            String s = (String) value;
	            if (s.length() == 0) {
	                addFieldError(fieldName, object);
	            }
	        }
	}

}
